﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity;

namespace CSP.Receipts.DataModel
{
    public class Receipt
    {
        private User _owner;
        
        public Receipt()
        {
            ReceiptPictures = new List<Picture>();
        }

        public int Id { get; set; }

        [StringLength(200)]
        [Required]
        public string Title { get; set; }

        public DateTime CreationDate { get; set; }

        [StringLength(255)]
        [DataType(DataType.Url)]
        public string Url { get; set; }

        public int PreparationTime { get; set; }

        public virtual ICollection<Picture> ReceiptPictures { get; set; }
        public virtual string ReceiptText { get; set; }

        public virtual Category Category { get; set; }

        public virtual User Owner
        {
            get
            {
                return _owner;
            }
            set
            {
                _owner = value;
                if (_owner != null)
                    OwnerId = _owner.Id;
            }
        }

        //NavigationProperties
        public int CategoryId { get; set; }
        [Required]
        public int OwnerId { get; set; }
    }
}